<?php
namespace App\Models\Resources;

use App\Models\Enum\SurveyQuestionEnum;
use Illuminate\Http\Resources\Json\JsonResource;

class SurveyQuestionRequest extends JsonResource
{
    public function toArray($request)
    {
        switch ($this->status){
            case -1:
                $this->status = '已删除';//deleted
                break;
            case 0:
                $this->status = '正常';//enable
                break;
            case 1:
                $this->status = '冻结';//disable
                break;
        }
        return [
            'id'=>$this->id,
            'name' => $this->name,
            'type' => $this->type,
            'type_name' => SurveyQuestionEnum::getTypeName($this->type),
            'survey_id'=>(string)$this->survey_id,
            'sort'=>(string)$this->sort,
            'count_participant'=>(string)$this->count_participant,
            'create_id'=>(string)$this->create_id,
            'create_at'=>(string)$this->create_at,
            'update_at'=>(string)$this->update_at,
        ];
    }
}
